//==============================================================================
#ifndef _MESSAGE_H
#define _MESSAGE_H

#pragma once
#include "net\ByteBuffer.h"
#include "..\..\Persistence\persistence\Tokenizer.h"
#include <string>
#include <list>

using namespace std;
//==============================================================================
typedef enum
{
	UNKNOWN_MESSAGE_TYPE,
	NEW_PLAYER_SESSION_REQUEST,
	NEW_OBSERVER_SESSION_REQUEST,
	NEW_SESSION_REQUEST_ACCEPTED,
	NEW_SESSION_REQUEST_REJECTED,
	GAME_FILES_REQUEST,
	SCENE_STATE_REQUEST,
	START_GAME,
	GAME_OVER,
	SESSION_READY,
	SESSION_END,
	SCENE_STATE,
	EVENT_MOVE_UP_ON,
	EVENT_MOVE_UP_OFF,
	EVENT_MOVE_DOWN_ON,
	EVENT_MOVE_DOWN_OFF,
	EVENT_ROT_LEFT_ON,
	EVENT_ROT_LEFT_OFF,
	EVENT_ROT_RIGHT_ON,
	EVENT_ROT_RIGHT_OFF,
	EVENT_SHOOT
} MESSAGE_TYPE;

class Message
{
public:
	Message(void);
	Message(MESSAGE_TYPE type, string data);
	Message(ByteBuffer* buffer);
	virtual ~Message(void);
	void setType(MESSAGE_TYPE type);
	MESSAGE_TYPE getType(void);
	static MESSAGE_TYPE toMessageType(int num);
	void setData(string data);
	string getData(void);

	list<MESSAGE_TYPE*>* unmarshalList(ByteBuffer* b);
	virtual void marshal(ByteBuffer* buffer);
	virtual void unmarshal(ByteBuffer* buffer);
	virtual string toString(void);

protected:
	MESSAGE_TYPE type;
	string data;
};
#endif;
